import time

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction

url = "http://127.0.0.1:4723/wd/hub"

param = {
    "deviceName": "6f3d92e1",  # 设备号
    "platformName": "Android",  # 系统名称
    "platformVersion": "13",  # 系统版本
    "appPackage": "com.chinamworld.main",  # 软件包名
    "appActivity": "com.ccb.start.MainActivity"  # 启动类名
}

driver = webdriver.Remote(url, param)

# el1 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.slidingpanelayout.widget.SlidingPaneLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View/android.view.View[1]/android.view.View/android.view.View[4]/android.widget.Image")
# el1.click()
el2 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"同意")
el2.click()
time.sleep(5)
TouchAction(driver).tap(x=1281, y=408).perform()
el3 = driver.find_element(MobileBy.XPATH,"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.slidingpanelayout.widget.SlidingPaneLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.LinearLayout/androidx.viewpager.widget.ViewPager/android.widget.FrameLayout/android.widget.ScrollView/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.webkit.WebView/android.webkit.WebView/android.view.View/android.view.View/android.view.View[1]/android.view.View/android.view.View[2]/android.view.View/android.view.View[1]/android.view.View/android.view.View[2]/android.widget.TextView")
el3.click()
time.sleep(5)
el4 = driver.find_element(MobileBy.ACCESSIBILITY_ID,"手机号转账")
el4.click()
time.sleep(40)
el1 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/et_cash_name")
el1.send_keys("仲鹏举")
time.sleep(2)
el2 = driver.find_element(MobileBy.ID,"com.chinamworld.main:id/et_collection_account")
el2.send_keys("18648298823")
time.sleep(2)


driver.quit()
